package com.seanbot.armstrong.poolgame;


public class BallThread extends Thread {

	private final static int SLEEP_TIME = 100;

	private boolean running = false;
	private PoolView canvas = null;

	public BallThread(PoolView canvas) {
		super();
		this.canvas = canvas;
	}

	public void startThread() {
		running = true;
		super.start();
	}

	public void stopThread() {
		running = false;
	}

	public void run() {
		while (running) {
			try {
				canvas.moveCircle();
				canvas.postInvalidate();
				sleep(SLEEP_TIME);
			} catch (InterruptedException ie) {
			}
		}
	}
}

// private boolean isRunning;
// private SurfaceHolder surfaceHolder;
// private PoolView pv;
// private Canvas canvas;
//
// public BallThread(SurfaceHolder surfaceHolder, PoolView pv) {
// super();
// this.surfaceHolder = surfaceHolder;
// this.pv = pv;
// }
//
// public void setRunning(boolean isRunning){
// this.isRunning = isRunning;
// }
//
// public void run() {
// while (isRunning) {
// // update game state
// // render state to the screen
// canvas = null;
// try{
// canvas = surfaceHolder.lockCanvas(null);
// synchronized(surfaceHolder) {
// pv.onDraw(canvas);
// }
// } finally {
// if(canvas != null) {
// surfaceHolder.unlockCanvasAndPost(canvas);
// }
// }
// }
// }
//
// }
